package com.yhb.hash.control;

import com.yhb.hash.bean.UserInfoBean;
import com.yhb.hash.model.UserModel;
import com.yhb.hash.utils.MyUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/deleteJump")
public class UserinfoDeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1 获取表单数据
        String strUserId=req.getParameter("id");
        //2 调用service方法进行删除操作

        //使用物理删除，删除数据
//        int i= MyUtils.getNewInstance(UserModel.class).deleteUserInfoById(strUserId);
        //逻辑删除
        int i = MyUtils.getNewInstance(UserModel.class).logicallyDeleteUserInfoById(strUserId);
        //3、删除之后的数据显示-跳转到查询显示页面即可
        List<UserInfoBean> lstUsers=MyUtils.getNewInstance(UserModel.class).queryUserInfoAll();
        req.getSession().setAttribute("lstUsers", lstUsers);
        req.getRequestDispatcher("WEB-INF/viewpages/userInfoB/UserInfoAddDetail.jsp").forward(req, resp);
    }
}
